import pulpcore.Stage;
import pulpcore.sprite.ImageSprite;

/** Used to represent the seesaw that players stand on before jumping up to the branch. */
public class Seesaw extends ImageSprite
{
	/**
	 * The Enum State.
	 */
	public static enum State
	{
		/** The NO t_ rotating. */
		NOT_ROTATING,
		/** The ROTATIN g_ left. */
		ROTATING_LEFT,
		/** The ROTATIN g_ right. */
		ROTATING_RIGHT
	}
	// TODO: Decide on seesaw height
	/** The height of the seesaw. */
	private static final int HEIGHT = 50;
	/** The Constant ROTATION_SPEED. */
	private static final double ROTATION_SPEED = .001;
	// TODO: Decide on seesaw width
	/** The width of the seesaw. */
	private static final int WIDTH = 775;
	/** The x anchor of the seesaw. */
	private static final double X_ANCHOR = .5;
	/** The y anchor of the seesaw. */
	private static final double Y_ANCHOR = 0;
	/** The state. */
	private State state;

	/**
	 * Instantiates a new seesaw.
	 * 
	 * @param imageAsset
	 *            the file name of the image to be used as the seesaw
	 * @param xProportion
	 *            the proportion that the seesaw should be at horizontally
	 * @param yProportion
	 *            the proportion that the seesaw should be at vertically
	 */
	public Seesaw(final String imageAsset, final double xProportion, final double yProportion)
	{
		super(imageAsset, xProportion * Stage.getWidth(), yProportion * Stage.getHeight(), WIDTH, HEIGHT);
		setAnchor(X_ANCHOR, Y_ANCHOR);
		angle.set(2 * Math.PI * .03);
		System.out.println(angle);
		state = State.NOT_ROTATING;
	}

	/**
	 * Gets the state.
	 * 
	 * @return the state
	 */
	public State getState()
	{
		return state;
	}

	/**
	 * Rotate.
	 * 
	 * @param elapsedTime
	 *            the elapsed time
	 */
	public void Rotate(final int elapsedTime)
	{
		int direction;
		switch (state)
		{
		default:
		case NOT_ROTATING:
			return;
		case ROTATING_LEFT:
			direction = -1;
			break;
		case ROTATING_RIGHT:
			direction = 1;
		}
		angle.set(angle.get() + (ROTATION_SPEED * direction * elapsedTime));
		System.out.println(angle.get());
	}

	/**
	 * Sets the state.
	 * 
	 * @param state
	 *            the new state
	 */
	public void setState(final State state)
	{
		this.state = state;
	}
}